package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

import com.example.administrator.myapplication.adapter.MyAdapter;
import com.example.administrator.myapplication.bean.Weather;
import com.example.administrator.myapplication.util.GetJsonDataUtil;
import com.google.gson.Gson;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ListView listview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();
        initEvent();
    }

    private void  initView(){
        listview = (ListView) findViewById(R.id.listview);


    }
    private  void initData(){
        String jsondate = new  GetJsonDataUtil().getJson(MainActivity.this,"data.json");
        Gson gson =new Gson();
        Weather weather= gson.fromJson(jsondate,Weather.class);
        String temperature= weather.getResult().getToday().getTemperature();
        Toast.makeText(MainActivity.this,temperature, Toast.LENGTH_SHORT).show();

        List<Weather.ResultBean.FutureBean> futureBeen = weather.getResult().getFuture();
        listview.setAdapter(new MyAdapter(MainActivity.this,futureBeen));

    }
    private void initEvent(){

    }
}
